package com.project.springboot.entity;

import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.project.springboot.annotation.ExcelEnumValue;
import com.project.springboot.converters.ExcelEnumValueConverter;
import com.project.springboot.enums.SexEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;

import java.io.Serializable;
import java.util.Date;

/**
 * 学生表(Student)表实体类
 * @author 朱正磊
 * @since 2023-08-16 00:00:20
 */
@EqualsAndHashCode(callSuper = false)
@Data
@TableName("tb_student")
@NoArgsConstructor
@AllArgsConstructor
@ExcelIgnoreUnannotated
public class Student extends Model<Student> {

    //主键
    @TableId(type = IdType.AUTO)
    @ExcelProperty("主键")
    private Integer id;

    //姓名
    @ExcelProperty("姓名")
    private String name;

    //性别：1-男；2-女
    @ExcelProperty(value = "性别", converter = ExcelEnumValueConverter.class)
    @ExcelEnumValue(SexEnum.class)
    private Integer sex;

    //年龄
    @ExcelProperty("年龄")
    private Integer age;

    //家庭住址
    @ExcelProperty("家庭住址")
    private String address;

    //爱好
    @ExcelProperty("爱好")
    private String hobby;

    //出生日期
    @ExcelProperty("出生日期")
    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    private Date birthday;

    /**
     * 获取主键值
     * @return 主键值
     */
    @Override
    public Serializable pkVal() {
        return this.id;
    }

}
